package com.tdam2013.grupo09.actividades;

import com.tdam2013.grupo09.R;

import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceChangeListener;

public class PreferenciaContactos extends PreferenceActivity {

	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferencia_contacto);

		ListPreference listPreference = (ListPreference) findPreference("opcion1");
		if (listPreference.getValue() == null) {
			listPreference.setValueIndex(0);
		}
		listPreference.setSummary(listPreference.getValue().toString());
		listPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
					@Override
					public boolean onPreferenceChange(Preference preference,Object newValue) {
						preference.setSummary(newValue.toString());
						Editor ed = preference.getEditor();
						ed.putString("opcion1", newValue.toString());
						ed.commit();
						return false;
					}
				});
	}

}
